package com.yyh;

public class Rectangle {
    //属性
    //长
    private double lang;
    //宽
    private double width;
    //无参构造方法
    public Rectangle() {
    }
    //有参构造方法
    public Rectangle(double lang, double width) {
        this.lang = lang;
        this.width = width;
    }
    //getter and setter
    public double getLang() {
        return lang;
    }

    public void setLang(double lang) {
        this.lang = lang;
    }

    public double getWidth() {
        return width;
    }

    public void setWidth(double width) {
        this.width = width;
    }
    //矩形面积方法
    public double getArea(){
        return lang * width;
    }
    //矩形周长方法
    public double getPerimeter(){
        return 2 * (lang + width);
    }
    //打印矩形信息方法
    public String getInfo(){
        return "长："+lang+",宽："+width+",面积："+this.getArea()+",周长："+this.getPerimeter();

    }
}
